#include <iostream>
#include <algorithm>
using namespace std;
int sum = 0;
int n = 0;
int T = 0;
int a[105];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> T;
    while (T--)
    {
        cin >> n;
        if (n > 2)
        {
            for (int i = 1; i <= n; i++)
            {
                cin >> a[i];
            }
            sort(a + 1, a + 1 + n);
            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    for (int k = 1; k <= n; k++)
                    {
                        if (i != j && j != k && i != k)
                        {
                            if (a[i] + a[j] == a[k])
                                sum += 1;
                        }
                    }
                }
            }
            cout << sum << '\n';
        }
        else
        {
            cout << 0 << '\n';
        }
    }
}